<style>
    html {
        background-color: #ffffff;
    }
</style>
<div class="user-api-form" style="background-color: #ffffff;">

    <form id="role-form" class="layui-form model-form" action="{{.Data.action}}" method="post"
          lay-filter="role-filter">

        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required" for="role-name">角色名称</label>
            <div class="layui-input-block">
                <input type="text" id="role-name" class="layui-input" name="name" maxlength="100"
                       lay-verify="required" aria-required="true" value="{{.Data.roleModel.Name}}"></div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required" for="role-identify">角色标识</label>
            <div class="layui-input-block">
                <input type="text" id="role-identify" class="layui-input" name="identify" maxlength="100"
                       lay-verify="required" aria-required="true" value="{{.Data.roleModel.Identify}}"></div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" for="role-sort">排序</label>
            <div class="layui-input-block">
                <input type="number" id="role-sort" class="layui-input" name="sort" aria-required="true"
                       value="{{.Data.roleModel.Sort}}"></div>
        </div>


        {{if eq $.Data.action "/admin/role/create" }}
            {{.BuildIn.DropDownList "status|状态|1|请选择状态|0" (.BuildIn.StatusStr 0 0) -1}}
        {{else}}
            {{.BuildIn.DropDownList "status|状态|1|请选择状态|0" (.BuildIn.StatusStr 0 0) $.Data.roleModel.Status}}
        {{end}}

        <div class="layui-form-item">
            <label class="layui-form-label" for="role-remark">备注</label>
            <div class="layui-input-block">
                <textarea id="role-remark" class="layui-textarea" name="remark">{{.Data.roleModel.Remark}}</textarea>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="btnSubmit" lay-submit="">保存</button>
        </div>
    </form>
</div>
<script type="application/javascript">
    layui.use(['layer', 'form', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var admin = layui.admin;
        var url = $('#role-form').attr('action');
        // admin.iframeAuto();  // 让当前iframe弹层高度适应
        // 表单提交事件
        form.on('submit(btnSubmit)', function (data) {
            layer.load(2);
            admin.req(url, data.field, function (data) {
                layer.closeAll('loading');
                if (data.code === 0) {
                    layer.msg(data.msg, {icon: 1});
                    admin.putTempData('t-role-form-ok', true);  // 操作成功刷新表格
                    // 关闭当前iframe弹出层
                    admin.closeThisDialog();
                } else {
                    layer.msg(data.msg, {icon: 2});
                }
            }, 'post');

            return false;
        })
    });
</script>